#tag Class
Protected Class ConcreteGame
	#tag Method, Flags = &h21
		Private Sub Constructor()
		  bag = new TileBag(generate)
		  board = new board.Gameboard
		  
		  
		  
		  #if DebugBuild
		    if bag.selfCheck = true then
		      MsgBox "Concrete Game Constructor"
		    end if
		  #endif
		  
		  'delete this line -> this is only for testing purposes
		  'currentPlayer = new meta.Player("Nattl", &cFF0000)
		  
		  currentTile = bag.getNextTile
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h21
		Private Function generate() As Tile()
		  dim tileArray() as Tile
		  dim i as integer
		  dim counterId as integer = 2
		  dim uniqueId as String
		  dim sCon as Connections
		  dim tCon as Connections
		  
		  //4 monastry-tiles with grassland
		  //monastry01
		  // 1 . .
		  // . 4 .
		  // . . .
		  
		  uniqueId = "MonasteryA"
		  
		  sCon.north = false
		  sCon.east = false
		  sCon.south = false
		  sCon.west = false
		  
		  tCon.north = false
		  tCon.east = false
		  tCon.south = false
		  tCon.west = false
		  
		  for i = 0 to 3
		    dim gameTile as new Tile
		    gameTile.type = uniqueId
		    gameTile.SetUid uniqueId + str(i+1)
		    gameTile.id = counterId
		    counterId = counterId + 1
		    gameTile.SetNorthSection(new board.Grassland(gameTile))
		    gameTile.SetEastSection(new board.Grassland(gameTile))
		    gameTile.SetSouthSection(new board.Grassland(gameTile))
		    gameTile.SetWestSection(new board.Grassland(gameTile))
		    gameTile.monastry = true
		    gameTile.grid.SetSlot("c", 4)
		    gameTile.grid.SetSlot("nw", 1)
		    gameTile.northPicture = Monastry01a_100x100
		    gameTile.eastpicture = Monastry01d_100x100
		    gameTile.southpicture = Monastry01c_100x100
		    gameTile.westpicture = Monastry01b_100x100
		    gameTile.setStreetConnections sCon
		    gameTile.setTownConnections tCon
		    tileArray.Append gameTile
		  next
		  
		  //2 monastry-tiles with street
		  //monastry02
		  // 1 . .
		  // . 4 .
		  // . 2 .
		  
		  uniqueId = "MonasteryB"
		  
		  sCon.north = false
		  sCon.east = false
		  sCon.south = false
		  sCon.west = false
		  
		  tCon.north = false
		  tCon.east = false
		  tCon.south = false
		  tCon.west = false
		  
		  for i = 0 to 1
		    dim gameTile as new Tile
		    gameTile.type = uniqueId
		    gameTile.SetUid uniqueId + str(i+1)
		    gameTile.id = counterId
		    counterId = counterId + 1
		    gameTile.SetNorthSection(new board.Grassland(gameTile))
		    gameTile.SetEastSection(new board.Grassland(gameTile))
		    gameTile.SetSouthSection(new board.Street(gameTile))
		    gameTile.SetWestSection(new board.Grassland(gameTile))
		    gameTile.monastry = true
		    gameTile.grid.SetSlot("c", 4)
		    gameTile.grid.SetSlot("nw", 1)
		    gameTile.grid.SetSlot("s", 2)
		    gameTile.northPicture = Monastry02a_100x100
		    gameTile.eastpicture = Monastry02d_100x100
		    gameTile.southpicture = Monastry02c_100x100
		    gameTile.westpicture = Monastry02b_100x100
		    gameTile.setStreetConnections sCon
		    gameTile.setTownConnections tCon
		    tileArray.Append gameTile
		  next i
		  
		  //1 full town-tile
		  // . . .
		  // . 3 .
		  // . . .
		  
		  uniqueId = "TownA"
		  
		  sCon.north = false
		  sCon.east = false
		  sCon.south = false
		  sCon.west = false
		  
		  tCon.north = true
		  tCon.east = true
		  tCon.south = true
		  tCon.west = true
		  
		  dim townTileA as new Tile
		  
		  TownTileA.type = uniqueId
		  TownTileA.SetUid uniqueId + str(i+1)
		  townTileA.id = counterId
		  counterId = counterId + 1
		  townTileA.SetNorthSection(new board.Town(townTileA))
		  townTileA.SetEastSection(new board.Town(townTileA))
		  townTileA.SetSouthSection(new board.Town(townTileA))
		  townTileA.SetWestSection(new board.Town(townTileA))
		  townTileA.coatOfArms = true
		  townTileA.grid.SetSlot("c", 1)
		  townTileA.northPicture = Town01a_100x100
		  townTileA.eastPicture = Town01d_100x100
		  townTileA.southPicture = Town01c_100x100
		  townTileA.westPicture = Town01b_100x100
		  townTileA.setStreetConnections sCon
		  townTileA.setTownConnections tCon
		  tileArray.Append townTileA
		  
		  //3x towntileB
		  // . . .
		  // . 3 .
		  // . 1 .
		  
		  uniqueId = "TownB"
		  
		  sCon.north = false
		  sCon.east = false
		  sCon.south = false
		  sCon.west = false
		  
		  tCon.north = true
		  tCon.east = true
		  tCon.south = false
		  tCon.west = true
		  
		  
		  for i = 0 to 2
		    dim townTileB as new Tile
		    townTileB.type = uniqueId
		    townTileB.SetUid uniqueId + str(i+1)
		    townTileB.id = counterId
		    counterId = counterId + 1
		    townTileB.SetNorthSection(new board.Town(townTileB))
		    townTileB.SetEastSection(new board.Town(townTileB))
		    townTileB.SetSouthSection(new board.Grassland(townTileB))
		    townTileB.SetWestSection(new board.Town(townTileB))
		    townTileB.grid.SetSlot("c", 3)
		    townTileB.grid.SetSlot("s", 1)
		    townTileB.northPicture = Town02a_100x100
		    townTileB.eastPicture = Town02d_100x100
		    townTileB.southPicture = Town02c_100x100
		    townTileB.westPicture = Town02b_100x100
		    townTileB.setStreetConnections sCon
		    townTileB.setTownConnections tCon
		    tileArray.Append townTileB
		  next i
		  
		  //1x townTileC
		  // . . .
		  // . 3 .
		  // . 1 .
		  uniqueId = "TownC"
		  
		  sCon.north = false
		  sCon.east = false
		  sCon.south = false
		  sCon.west = false
		  
		  tCon.north = true
		  tCon.east = true
		  tCon.south = false
		  tCon.west = true
		  
		  dim townTileC as new Tile
		  townTileC.type = uniqueId
		  townTileC.SetUid uniqueId + str(1)
		  townTileC.id = counterId
		  counterId = counterId + 1
		  townTileC.SetNorthSection(new board.Town(townTileC))
		  townTileC.SetEastSection(new board.Town(townTileC))
		  townTileC.SetSouthSection(new board.Grassland(townTileC))
		  townTileC.SetWestSection(new board.Town(townTileC))
		  townTileC.grid.SetSlot("c", 3)
		  townTileC.grid.SetSlot("s", 1)
		  townTileC.coatOfArms = true
		  townTileC.northPicture = Town03a_100x100
		  townTileC.eastPicture = Town03d_100x100
		  townTileC.southPicture = Town03c_100x100
		  townTileC.westPicture = Town03b_100x100
		  townTileC.setStreetConnections sCon
		  townTileC.setTownConnections tCon
		  tileArray.Append townTileC
		  
		  //1x townTileD
		  // . . .
		  // . 3 .
		  // 1 2 1
		  
		  uniqueId = "TownD"
		  
		  sCon.north = false
		  sCon.east = false
		  sCon.south = false
		  sCon.west = false
		  
		  tCon.north = true
		  tCon.east = true
		  tCon.south = false
		  tCon.west = true
		  
		  dim townTileD as new Tile
		  townTileD.type = uniqueId
		  townTileD.SetUid uniqueId + str(1)
		  townTileD.id = counterId
		  counterId = counterId + 1
		  townTileD.SetNorthSection(new board.Town(townTileD))
		  townTileD.SetEastSection(new board.Town(townTileD))
		  townTileD.SetSouthSection(new board.Street(townTileD))
		  townTileD.SetWestSection(new board.Town(townTileD))
		  townTileC.grid.SetSlot("c", 3)
		  townTileD.grid.SetSlot("se", 1)
		  townTileD.grid.SetSlot("s", 2)
		  townTileD.grid.SetSlot("sw", 1)
		  townTileD.northPicture = Town04a_100x100
		  townTileD.eastPicture = Town04d_100x100
		  townTileD.southPicture = Town04c_100x100
		  townTileD.westPicture = Town04b_100x100
		  townTileD.setStreetConnections sCon
		  townTileD.setTownConnections tCon
		  tileArray.Append townTileD
		  
		  //2x townTileE
		  // . . .
		  // . 3 .
		  // 1 2 1
		  
		  uniqueId = "TownE"
		  
		  sCon.north = false
		  sCon.east = false
		  sCon.south = false
		  sCon.west = false
		  
		  tCon.north = true
		  tCon.east = true
		  tCon.south = false
		  tCon.west = true
		  
		  for i = 0 to 1
		    dim townTileE as new Tile
		    townTileE.type = uniqueId
		    townTileE.SetUid uniqueId + str(i+1)
		    townTileE.id = counterId
		    counterId = counterId + 1
		    townTileE.SetNorthSection(new board.Town(townTileE))
		    townTileE.SetEastSection(new board.Town(townTileE))
		    townTileE.SetSouthSection(new board.Street(townTileE))
		    townTileE.SetWestSection(new board.Town(townTileE))
		    townTileE.grid.SetSlot("c", 3)
		    townTileE.grid.SetSlot("se",1)
		    townTileE.grid.SetSlot("s", 2)
		    townTileE.grid.SetSlot("sw", 1)
		    townTileE.coatOfArms = true
		    townTileE.northPicture = Town05a_100x100
		    townTileE.eastPicture = Town05d_100x100
		    townTileE.southPicture = Town05c_100x100
		    townTileE.westPicture = Town05b_100x100
		    townTileE.setStreetConnections sCon
		    townTileE.setTownConnections tCon
		    tileArray.Append townTileE
		  next i
		  
		  
		  //3x town TileF
		  // 3 . .
		  // . . .
		  // . . 1
		  uniqueId = "TownF"
		  
		  sCon.north = false
		  sCon.east = false
		  sCon.south = false
		  sCon.west = false
		  
		  tCon.north = true
		  tCon.east = false
		  tCon.south = false
		  tCon.west = true
		  
		  for i = 0 to 2
		    dim townTileF as new Tile
		    townTileF.type = uniqueId
		    townTileF.SetUid uniqueId + str(i+1)
		    townTileF.id = counterId
		    counterId = counterId + 1
		    townTileF.SetNorthSection(new board.Town(townTileF))
		    townTileF.SetEastSection(new board.Grassland(townTileF))
		    townTileF.SetSouthSection(new board.Grassland(townTileF))
		    townTileF.SetWestSection(new board.Town(townTileF))
		    townTileF.grid.SetSlot("nw", 3)
		    townTileF.grid.SetSlot("se", 1)
		    townTileF.northPicture = Town06a_100x100
		    townTileF.eastPicture = Town06d_100x100
		    townTileF.southPicture = Town06c_100x100
		    townTileF.westPicture = Town06b_100x100
		    townTileF.setStreetConnections sCon
		    townTileF.setTownConnections tCon
		    tileArray.Append townTileF
		  next i
		  
		  
		  //2x town TileG
		  // 3 . .
		  // . . .
		  // . . 1
		  uniqueId = "TownG"
		  
		  sCon.north = false
		  sCon.east = false
		  sCon.south = false
		  sCon.west = false
		  
		  tCon.north = true
		  tCon.east = false
		  tCon.south = false
		  tCon.west = true
		  
		  for i = 0 to 1
		    dim townTileG as new Tile
		    townTileG.type = uniqueId
		    townTileG.SetUid uniqueId + str(i+1)
		    townTileG.id = counterId
		    counterId = counterId + 1
		    townTileG.SetNorthSection(new board.Town(townTileG))
		    townTileG.SetEastSection(new board.Grassland(townTileG))
		    townTileG.SetSouthSection(new board.Grassland(townTileG))
		    townTileG.SetWestSection(new board.Town(townTileG))
		    townTileG.grid.SetSlot("nw", 3)
		    townTileG.grid.SetSlot("se", 1)
		    townTileG.coatOfArms = true
		    townTileG.northPicture = Town07a_100x100
		    townTileG.eastPicture = Town07d_100x100
		    townTileG.southPicture = Town07c_100x100
		    townTileG.westPicture = Town07b_100x100
		    townTileG.setStreetConnections sCon
		    townTileG.setTownConnections tCon
		    tileArray.Append townTileG
		  next i
		  
		  
		  //3x townTileH
		  // 3 . .
		  // . 1 2
		  // . . 1
		  uniqueId = "TownH"
		  
		  sCon.north = false
		  sCon.east = true
		  sCon.south = true
		  sCon.west = false
		  
		  tCon.north = true
		  tCon.east = false
		  tCon.south = false
		  tCon.west = true
		  
		  for i = 0 to 2
		    dim townTileH as new Tile
		    townTileH.type = uniqueId
		    townTileH.SetUid uniqueId + str(i+1)
		    townTileH.id = counterId
		    counterId = counterId + 1
		    townTileH.SetNorthSection(new board.Town(townTileH))
		    townTileH.SetEastSection(new board.Street(townTileH))
		    townTileH.SetSouthSection(new board.Street(townTileH))
		    townTileH.SetWestSection(new board.Town(townTileH))
		    townTileH.grid.SetSlot("nw", 3)
		    townTileH.grid.SetSlot("c", 1)
		    towntileH.grid.SetSlot("e", 2)
		    townTileH.grid.SetSlot("se", 1)
		    townTileH.northPicture = Town08a_100x100
		    townTileH.eastPicture = Town08d_100x100
		    townTileH.southPicture = Town08c_100x100
		    townTileH.westPicture = Town08b_100x100
		    townTileH.setStreetConnections sCon
		    townTileH.setTownConnections tCon
		    tileArray.Append townTileH
		  next i
		  
		  //2x townTileI
		  // 3 . .
		  // . 1 2
		  // . . 1
		  uniqueId = "TownI"
		  
		  sCon.north = false
		  sCon.east = true
		  sCon.south = true
		  sCon.west = false
		  
		  tCon.north = true
		  tCon.east = false
		  tCon.south = false
		  tCon.west = true
		  
		  for i = 0 to 1
		    dim townTileI as new Tile
		    townTileI.type = uniqueId
		    townTileI.SetUid uniqueId + str(i+1)
		    townTileI.id = counterId
		    counterId = counterId + 1
		    townTileI.SetNorthSection(new board.Town(townTileI))
		    townTileI.SetEastSection(new board.Street(townTileI))
		    townTileI.SetSouthSection(new board.Street(townTileI))
		    townTileI.SetWestSection(new board.Town(townTileI))
		    townTileI.grid.SetSlot("nw", 3)
		    townTileI.grid.SetSlot("c", 1)
		    towntileI.grid.SetSlot("e", 2)
		    townTileI.grid.SetSlot("se", 1)
		    townTileI.coatOfArms = true
		    townTileI.northPicture = Town09a_100x100
		    townTileI.eastPicture = Town09d_100x100
		    townTileI.southPicture = Town09c_100x100
		    townTileI.westPicture = Town09b_100x100
		    townTileI.setStreetConnections sCon
		    townTileI.setTownConnections tCon
		    tileArray.Append townTileI
		  next i
		  
		  
		  //1x towntile j
		  // . 1 .
		  // . 3 .
		  // . 1 .
		  uniqueId = "TownJ"
		  
		  sCon.north = false
		  sCon.east = false
		  sCon.south = false
		  sCon.west = false
		  
		  tCon.north = false
		  tCon.east = true
		  tCon.south = false
		  tCon.west = true
		  
		  dim townTileJ as new Tile
		  townTileJ.type = uniqueId
		  townTileJ.SetUid uniqueId + str(1)
		  townTileJ.id = counterId
		  counterId = counterId + 1
		  townTileJ.SetNorthSection(new board.Grassland(townTileJ))
		  townTileJ.SetEastSection(new board.Town(townTileJ))
		  townTileJ.SetSouthSection(new board.Grassland(townTileJ))
		  townTileJ.SetWestSection(new board.Town(townTileJ))
		  townTileJ.grid.SetSlot("n", 1)
		  townTileJ.grid.SetSlot("c", 3)
		  townTileJ.grid.SetSlot("s", 1)
		  townTileJ.northPicture = Town10a_100x100
		  townTileJ.eastPicture = Town10d_100x100
		  townTileJ.southPicture = Town10c_100x100
		  townTileJ.westPicture = Town10b_100x100
		  townTileJ.setStreetConnections sCon
		  townTileJ.setTownConnections tCon
		  tileArray.Append townTileJ
		  
		  
		  //2x towntile k
		  // . 1 .
		  // . 3 .
		  // . 1 .
		  uniqueId = "TownK"
		  
		  sCon.north = false
		  sCon.east = false
		  sCon.south = false
		  sCon.west = false
		  
		  tCon.north = false
		  tCon.east = true
		  tCon.south = false
		  tCon.west = true
		  
		  for i = 0 to 1
		    dim townTileK as new Tile
		    towntilek.type = uniqueId
		    townTileK.SetUid uniqueId + str(i+1)
		    townTileK.id = counterId
		    counterId = counterId + 1
		    townTileK.SetNorthSection(new board.Grassland(townTileK))
		    townTileK.SetEastSection(new board.Town(townTileK))
		    townTileK.SetSouthSection(new board.Grassland(townTileK))
		    townTileK.SetWestSection(new board.Town(townTileK))
		    townTileK.grid.SetSlot("n", 1)
		    townTileK.grid.SetSlot("c", 3)
		    townTileK.grid.SetSlot("s", 1)
		    townTileK.coatOfArms = true
		    townTileK.northPicture = Town11a_100x100
		    townTileK.eastPicture = Town11d_100x100
		    townTileK.southPicture = Town11c_100x100
		    townTileK.westPicture = Town11b_100x100
		    townTileK.setStreetConnections sCon
		    townTileK.setTownConnections tCon
		    tileArray.Append townTileK
		  next i
		  
		  //2x towntile L
		  // . 3 .
		  // 3 1 .
		  // . . .
		  uniqueId = "TownL"
		  
		  sCon.north = false
		  sCon.east = false
		  sCon.south = false
		  sCon.west = false
		  
		  tCon.north = false
		  tCon.east = false
		  tCon.south = false
		  tCon.west = false
		  
		  for i = 0 to 1
		    dim townTileL as new Tile
		    townTileL.type = uniqueId
		    townTileL.SetUid uniqueId + str(i+1)
		    townTileL.id = counterId
		    counterId = counterId + 1
		    townTileL.SetNorthSection(new board.Town(townTileL))
		    townTileL.SetEastSection(new board.Grassland(townTileL))
		    townTileL.SetSouthSection(new board.Grassland(townTileL))
		    townTileL.SetWestSection(new board.Town(townTileL))
		    townTileL.grid.SetSlot("n", 3)
		    townTileL.grid.SetSlot("c", 1)
		    townTileL.grid.SetSlot("w", 3)
		    townTileL.northPicture = Town12a_100x100
		    townTileL.eastPicture = Town12d_100x100
		    townTileL.southPicture = Town12c_100x100
		    townTileL.westPicture = Town12b_100x100
		    townTileL.setStreetConnections sCon
		    townTileL.setTownConnections tCon
		    townTileL.setIsSingleTown true
		    tileArray.Append townTileL
		  next i
		  
		  //3x towntile m
		  // . 3 .
		  // . 1 .
		  // . 3 .
		  uniqueId = "TownM"
		  
		  sCon.north = false
		  sCon.east = false
		  sCon.south = false
		  sCon.west = false
		  
		  tCon.north = false
		  tCon.east = false
		  tCon.south = false
		  tCon.west = false
		  
		  for i = 0 to 2
		    dim townTileM as new Tile
		    townTileM.type = uniqueId
		    townTileM.SetUid uniqueId + str(i+1)
		    townTileM.id = counterId
		    counterId = counterId + 1
		    townTileM.SetNorthSection(new board.Town(townTileM))
		    townTileM.SetEastSection(new board.Grassland(townTileM))
		    townTileM.SetSouthSection(new board.Town(townTileM))
		    townTileM.SetWestSection(new board.Grassland(townTileM))
		    townTileM.grid.SetSlot("n", 3)
		    townTileM.grid.SetSlot("c", 1)
		    townTileM.grid.SetSlot("s", 3)
		    townTileM.northPicture = Town13a_100x100
		    townTileM.eastPicture = Town13d_100x100
		    townTileM.southPicture = Town13c_100x100
		    townTileM.westPicture = Town13b_100x100
		    townTileM.setStreetConnections sCon
		    townTileM.setTownConnections tCon
		    townTileM.setIsSingleTown true
		    tileArray.Append townTileM
		  next i
		  
		  //5x towntile n
		  // . 3 .
		  // . 1 .
		  // . . .
		  uniqueId = "TownN"
		  
		  sCon.north = false
		  sCon.east = false
		  sCon.south = false
		  sCon.west = false
		  
		  tCon.north = false
		  tCon.east = false
		  tCon.south = false
		  tCon.west = false
		  
		  for i = 0 to 4
		    dim townTileN as new Tile
		    townTileN.type = uniqueId
		    townTileN.SetUid uniqueId + str(i+1)
		    townTileN.id = counterId
		    counterId = counterId + 1
		    townTileN.SetNorthSection(new board.Town(townTileN))
		    townTileN.SetEastSection(new board.Grassland(townTileN))
		    townTileN.SetSouthSection(new board.Grassland(townTileN))
		    townTileN.SetWestSection(new board.Grassland(townTileN))
		    townTileN.grid.SetSlot("n", 3)
		    townTileN.grid.SetSlot("c", 1)
		    townTileN.northPicture = Town14a_100x100
		    townTileN.eastPicture = Town14d_100x100
		    townTileN.southPicture = Town14c_100x100
		    townTileN.westPicture = Town14b_100x100
		    townTileN.setStreetConnections sCon
		    townTileN.setTownConnections tCon
		    townTileN.SetIsSingleTown true
		    tileArray.Append townTileN
		  next i
		  
		  //3x towntile o
		  // . 3 .
		  // . . 1
		  // 1 2 .
		  uniqueId = "TownO"
		  
		  sCon.north = false
		  sCon.east = false
		  sCon.south = true
		  sCon.west = true
		  
		  tCon.north = false
		  tCon.east = false
		  tCon.south = false
		  tCon.west = false
		  
		  for i = 0 to 2
		    dim townTileO as new Tile
		    towntileO.type = uniqueId
		    townTileO.SetUid uniqueId + str(i+1)
		    townTileO.id = counterId
		    counterId = counterId + 1
		    townTileO.SetNorthSection(new board.Town(townTileO))
		    townTileO.SetEastSection(new board.Grassland(townTileO))
		    townTileO.SetSouthSection(new board.Street(townTileO))
		    townTileO.SetWestSection(new board.Street(townTileO))
		    townTileO.grid.SetSlot("n", 3)
		    townTileO.grid.SetSlot("e", 1)
		    townTileO.grid.SetSlot("sw", 1)
		    townTileO.grid.SetSlot("s", 2)
		    townTileO.northPicture = Town15a_100x100
		    townTileO.eastPicture = Town15d_100x100
		    townTileO.southPicture = Town15c_100x100
		    townTileO.westPicture = Town15b_100x100
		    townTileO.setStreetConnections sCon
		    townTileO.setTownConnections tCon
		    townTileO.setIsSingleTown true
		    tileArray.Append townTileO
		  next i
		  
		  
		  //3x towntile p
		  // . 3 .
		  // 1 . .
		  // . 2 1
		  uniqueId = "TownP"
		  
		  sCon.north = false
		  sCon.east = true
		  sCon.south = true
		  sCon.west = false
		  
		  tCon.north = false
		  tCon.east = false
		  tCon.south = false
		  tCon.west = false
		  
		  for i = 0 to 2
		    dim townTileP as new Tile
		    townTileP.type = uniqueId
		    townTileP.SetUid uniqueId + str(i+1)
		    townTileP.id = counterId
		    counterId = counterId + 1
		    townTileP.SetNorthSection(new board.Town(townTileP))
		    townTileP.SetEastSection(new board.Street(townTileP))
		    townTileP.SetSouthSection(new board.Street(townTileP))
		    townTileP.SetWestSection(new board.Grassland(townTileP))
		    townTileP.grid.SetSlot("n", 3)
		    townTileP.grid.SetSlot("se", 1)
		    townTileP.grid.SetSlot("s", 2)
		    townTileP.grid.SetSlot("w", 1)
		    townTileP.northPicture = Town16a_100x100
		    townTileP.eastPicture = Town16d_100x100
		    townTileP.southPicture = Town16c_100x100
		    townTileP.westPicture = Town16b_100x100
		    townTileP.setStreetConnections sCon
		    townTileP.setTownConnections tCon
		    townTileP.setIsSingleTown true
		    tileArray.Append townTileP
		  next i
		  
		  //3x towntile q
		  // 1 3 .
		  // 2 . 2
		  // 1 2 1
		  uniqueId = "TownQ"
		  
		  sCon.north = false
		  sCon.east = false
		  sCon.south = false
		  sCon.west = false
		  
		  tCon.north = false
		  tCon.east = false
		  tCon.south = false
		  tCon.west = false
		  
		  for i = 0 to 2
		    dim townTileQ as new Tile
		    townTileQ.type = uniqueId
		    townTileQ.SetUid uniqueId + str(i+1)
		    townTileQ.id = counterId
		    counterId = counterId + 1
		    townTileQ.SetNorthSection(new board.Town(townTileQ))
		    townTileQ.SetEastSection(new board.Street(townTileQ))
		    townTileQ.SetSouthSection(new board.Street(townTileQ))
		    townTileQ.SetWestSection(new board.Street(townTileQ))
		    townTileQ.grid.SetSlot("n", 3)
		    townTileQ.grid.SetSlot("nw", 1)
		    townTileQ.grid.SetSlot("e", 2)
		    townTileQ.grid.SetSlot("se", 1)
		    townTileQ.grid.SetSlot("s", 2)
		    townTileQ.grid.SetSlot("sw", 1)
		    townTileQ.grid.SetSlot("w", 2)
		    townTileQ.crossroads = true
		    townTileQ.northPicture = Town17a_100x100
		    townTileQ.eastPicture = Town17d_100x100
		    townTileQ.southPicture = Town17c_100x100
		    townTileQ.westPicture = Town17b_100x100
		    townTileQ.setStreetConnections sCon
		    townTileQ.setTownConnections tCon
		    townTileQ.setIsSingleTown true
		    tileArray.Append townTileQ
		  next i
		  
		  //3x towntile R
		  // 1 3 .
		  // . 2 .
		  // . 1 .
		  uniqueId = "TownR"
		  
		  sCon.north = false
		  sCon.east = true
		  sCon.south = true
		  sCon.west = false
		  
		  tCon.north = false
		  tCon.east = false
		  tCon.south = false
		  tCon.west = false
		  for i = 0 to 3
		    dim townTileR as new Tile
		    townTileR.type = uniqueId
		    townTileR.SetUid uniqueId + str(i+1)
		    townTileR.id = counterId
		    counterId = counterId + 1
		    townTileR.SetNorthSection(new board.Town(townTileR))
		    townTileR.SetEastSection(new board.Street(townTileR))
		    townTileR.SetWestSection(new board.Street(townTileR))
		    townTileR.SetSouthSection(new board.Grassland(townTileR))
		    townTileR.grid.SetSlot("n", 3)
		    townTileR.grid.SetSlot("nw", 1)
		    townTileR.grid.SetSlot("c", 2)
		    townTileR.grid.SetSlot("s", 1)
		    townTileR.northPicture = Town18a_100x100
		    townTileR.eastPicture = Town18d_100x100
		    townTileR.southPicture = Town18c_100x100
		    townTileR.westPicture = Town18b_100x100
		    townTileR.setStreetConnections sCon
		    townTileR.setTownConnections tCon
		    townTileR.setIsSingleTown true
		    tileArray.Append townTileR
		  next i
		  
		  //8x grassland a
		  // . . .
		  // 1 2 1
		  // . . .
		  uniqueId = "GrasslandA"
		  
		  sCon.north = true
		  sCon.east = false
		  sCon.south = true
		  sCon.west = false
		  
		  tCon.north = false
		  tCon.east = false
		  tCon.south = false
		  tCon.west = false
		  
		  for i = 0 to 7
		    dim grasslandTileA as new Tile
		    grasslandTileA.type = uniqueId
		    grasslandTileA.SetUid uniqueId + str(i+1)
		    grasslandTileA.id = counterId
		    counterId = counterId + 1
		    grasslandTileA.SetNorthSection(new board.Street(grasslandTileA))
		    grasslandTileA.SetEastSection(new board.Grassland(grasslandTileA))
		    grasslandTileA.SetSouthSection(new board.Street(grasslandTileA))
		    grasslandTileA.SetWestSection(new board.Grassland(grasslandTileA))
		    grasslandTileA.grid.SetSlot("w", 1)
		    grasslandTileA.grid.SetSlot("c", 2)
		    grasslandTileA.grid.SetSlot("e", 1)
		    grasslandTileA.northPicture = Grassland01a_100x100
		    grasslandTileA.eastPicture = Grassland01d_100x100
		    grasslandTileA.southPicture = Grassland01c_100x100
		    grasslandTileA.westPicture = Grassland01b_100x100
		    grasslandTileA.setStreetConnections sCon
		    grasslandTileA.setTownConnections tCon
		    tileArray.Append grasslandTileA
		  next i
		  
		  //9x grassland b
		  // . . 1
		  // . . .
		  // 1 2 .
		  uniqueId = "GrasslandB"
		  
		  sCon.north = false
		  sCon.east = false
		  sCon.south = true
		  sCon.west = true
		  
		  tCon.north = false
		  tCon.east = false
		  tCon.south = false
		  tCon.west = false
		  
		  for i = 0 to 8
		    dim grasslandTileB as new Tile
		    grasslandTileB.type = uniqueId
		    grasslandTileB.SetUid uniqueId + str(i+1)
		    grasslandTileB.id = counterId
		    counterId = counterId + 1
		    grasslandTileB.SetNorthSection(new board.Grassland(grasslandTileB))
		    grasslandTileB.SetEastSection(new board.Grassland(grasslandTileB))
		    grasslandTileB.SetSouthSection(new board.Street(grasslandTileB))
		    grasslandTileB.SetWestSection(new board.Street(grasslandTileB))
		    grasslandTileB.grid.SetSlot("ne", 1)
		    grasslandTileB.grid.SetSlot("s", 2)
		    grasslandTileB.grid.SetSlot("sw", 1)
		    grasslandTileB.northPicture = Grassland02a_100x100
		    grasslandTileB.eastPicture = Grassland02d_100x100
		    grasslandTileB.southPicture = Grassland02c_100x100
		    grasslandTileB.westPicture = Grassland02b_100x100
		    grasslandTileB.setStreetConnections sCon
		    grasslandTileB.setTownConnections tCon
		    tileArray.Append grasslandTileB
		  next i
		  
		  //4x village A
		  // . 1 .
		  // 2 . 2
		  // 1 2 1
		  uniqueId = "VillageA"
		  
		  sCon.north = false
		  sCon.east = false
		  sCon.south = false
		  sCon.west = false
		  
		  tCon.north = false
		  tCon.east = false
		  tCon.south = false
		  tCon.west = false
		  
		  for i = 0 to 3
		    dim villageTile01 as new Tile
		    villageTile01.type = uniqueId
		    villageTile01.SetUid uniqueId + str(i+1)
		    villageTile01.id = counterId
		    counterId = counterId + 1
		    villageTile01.SetNorthSection(new board.Grassland(villageTile01))
		    villageTile01.SetEastSection(new board.Street(villageTile01))
		    villageTile01.SetSouthSection(new board.Street(villageTile01))
		    villageTile01.SetWestSection(new board.Street(villageTile01))
		    villageTile01.grid.SetSlot("n", 1)
		    villageTile01.grid.Setslot("e", 2)
		    villageTile01.grid.SetSlot("se", 1)
		    villageTile01.grid.SetSlot("s", 2)
		    villageTile01.grid.SetSlot("sw", 1)
		    villageTile01.grid.SetSlot("w", 2)
		    villageTile01.crossroads = true
		    villageTile01.northPicture = Village01a_100x100
		    villageTile01.eastPicture = Village01d_100x100
		    villageTile01.southPicture = Village01c_100x100
		    villageTile01.westPicture = Village01b_100x100
		    villageTile01.setStreetConnections sCon
		    villageTile01.setTownConnections tCon
		    tileArray.append villagetile01
		  next i
		  
		  
		  //1x village2
		  // 1 2 1
		  // 2 . 2
		  // 1 2 1
		  uniqueId = "VillageB"
		  
		  sCon.north = false
		  sCon.east = false
		  sCon.south = false
		  sCon.west = false
		  
		  tCon.north = false
		  tCon.east = false
		  tCon.south = false
		  tCon.west = false
		  
		  dim villageTile02 as new Tile
		  
		  villageTile02.SetUid uniqueId + str(1)
		  villageTile02.id = counterId
		  villageTile02.type = uniqueId
		  counterId = counterId + 1
		  villageTile02.SetNorthSection(new board.Street(villageTile02))
		  villageTile02.SetEastSection(new board.Street(villageTile02))
		  villageTile02.SetSouthSection(new board.Street(villageTile02))
		  villageTile02.SetWestSection(new board.Street(villageTile02))
		  villageTile02.grid.SetSlot("n", 2)
		  villageTile02.grid.SetSlot("nw", 1)
		  villageTile02.grid.Setslot("e", 2)
		  villageTile02.grid.SetSlot("se", 1)
		  villageTile02.grid.SetSlot("s", 2)
		  villageTile02.grid.SetSlot("sw", 1)
		  villageTile02.grid.SetSlot("w", 2)
		  villageTile02.grid.SetSlot("nw", 1)
		  villageTile02.crossroads = true
		  villageTile02.northPicture = Village02a_100x100
		  villageTile02.eastPicture = Village02d_100x100
		  villageTile02.southPicture = Village02c_100x100
		  villageTile02.westPicture = Village02b_100x100
		  villageTile02.setStreetConnections sCon
		  villageTile02.setTownConnections tCon
		  tileArray.append villageTile02
		  
		  return tileArray
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GetCurrentPlayerName() As String
		  return currentPlayer.GetName
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GetNextTile() As Tile
		  dim placeable as boolean
		  dim i as integer
		  
		  
		  if not bag.IsEmpty then
		    currentTile = bag.GetNextTile
		    
		    placeable = false
		    
		    
		    
		    'check if the currently drawn tile can be placed on
		    'the gameboard in all possible ways.
		    'if it can't be placed, it is given back to the tilebag
		    '(which is then reshuffled)
		    for i = 0 to 3
		      currentTile.RotateClockwise
		      if  UBound(GetPossibleCoordinatesForTile()) <> -1 then
		        placeable = true
		        exit for
		      end if
		    next i
		    
		    if placeable = false then
		      bag.ReturnTileToBag currentTile
		      currentTile = GetNextTile
		    end if
		    
		    currentTile.ResetPosition
		    
		    'update the number of remaining tiles in the gui
		    winMain.txtTilesLeft.Text = str(bag.GetNumberOfTilesLeft)
		    
		    return currentTile
		  else
		    
		    //todo final score
		    
		    msgbox "Game ends!"
		    
		    
		    
		    
		  end if
		  
		  
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function AddTileAtPosition(newTile as Tile, position as Coordinates) As boolean
		  return board.AddTileAtPosition(newTile, position)
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GetPositionIsFree(position as Coordinates) As boolean
		  return board.GetPositionIsFree(position)
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GetPossibleCoordinatesForTile() As Coordinates()
		  
		  return board.GetPossibleCoordinatesForTile(currentTile)
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GetRemainingTiles() As Tile()
		  return bag.GetRemainingTiles
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GetTiles() As Tile()
		  return self.board.GetTiles
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub RotateClockwise()
		  if currentTile <> nil then
		    currentTile.RotateClockwise
		  end if
		  
		  'todo errorhandling
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub RotateCounterclockwise()
		  if currentTile <> nil then
		    currentTile.RotateCounterClockwise
		  end if
		  
		  'todo errorhandling
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GetCurrentTile() As Tile
		  return currentTile
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function Instance() As concreteGame
		  if gameInstance = nil then
		    gameInstance = new ConcreteGame
		  end if
		  
		  return gameInstance
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function GetNewGameInstance() As concreteGame
		  'this method is to be used if there is already a game
		  'running and a new game is explicitely started
		  'it then returns a new instance of game and not just
		  'the singleton
		  
		  gameInstance = nil
		  return Instance
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub AddPlayer(data as playerdata)
		  dim player as new Player(data.name, GetColor, data.type, data.aiType, self)
		  
		  if UBound(players)+1 < app.MAXPLAYERS then
		    
		    players.Append player
		    
		    if ubound(players) = 0 then
		      //set the first added player to currentPlayer
		      currentPlayer = players(0)
		      //activate it
		      'currentPlayer.Activate
		    end if
		  else
		    app.RaiseError(301,"Max no. of allowed players exceeded", "game.ConcreteGame.AddPlayer", 3)
		  end if
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h21
		Private Function GetColor() As color
		  
		  
		  select case ubound(players)
		  case -1
		    return PlayerColors.Red
		  case 0
		    return PlayerColors.Green
		  case 1
		    return PlayerColors.Yellow
		  case 2
		    return PlayerColors.Blue
		  case 3
		    return PlayerColors.Black
		  end select
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GetNumberOfPlayers() As Integer
		  return UBound(players) +1
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GetPlayerById(id as integer) As Player
		  return players(id)
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub NextPlayer()
		  dim nextPlayerIndex as integer
		  
		  nextPlayerIndex = players.IndexOf(currentPlayer)
		  
		  if nextPlayerIndex = UBound(players) then
		    nextPlayerIndex = 0
		    NewRound
		  else
		    nextPlayerIndex = nextPlayerIndex + 1
		  end if
		  
		  
		  currentPlayer = players(nextPlayerIndex)
		  
		  currentplayer.Activate
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GetCurrentPlayer() As player
		  return currentPlayer
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub NewRound()
		  round = round + 1
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub Update()
		  
		  if currentTile.grid.GetIsOccupied then
		    
		    select case currentTile.grid.GetOccupiedType
		    case "Monastery"
		      Monasteries.Append currentTile
		    case "Town"
		      Towns.Append currentTile
		    case "Street"
		      Streets.Append currentTile
		    else
		      app.RaiseError(401, "Occupied tile with slot of type 'undefined'", "ConcreteGame.Update", 2)
		    end select
		  else
		    app.RaiseError(402, "Tile should be occupied", "ConcreteGame.Update", 2)
		  end if
		  
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub UseCustomTileBag(tb as tilebag)
		  #if DebugBuild
		    //only useable for unittests to create a mock-tilebag
		    
		    bag = tb
		  #endif
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub CalculateScore()
		  'dim score as integer = 0
		  dim i as integer
		  dim j as integer
		  dim index as integer
		  dim theTile as Tile
		  dim theScore as game.Score
		  dim thePlayer as game.Player
		  dim pos as Coordinates
		  dim broom() as Tile
		  
		  
		  //todo Monasteries
		  for i = 0 to ubound(monasteries)
		    theTile = monasteries(i)
		    theScore = theTile.GetMonasteryEstates
		    if theScore <> nil then //if an occupied monastery with full tiles has been found
		      thePlayer = GetPlayerByColor(theScore.GetOwnerColor)
		      if thePlayer <> nil then
		        thePlayer.SetScore theScore.GetScore
		        'theTile.grid.FreeSlots
		        remove theTile
		        theTile.RemoveOwner
		        'monasteries.Remove monasteries.IndexOf(theTile)
		        app.Dbg = app.dbg + thePlayer.Getname + " Monastery + " + str(theScore.GetScore) + EndOfLine
		      end if
		    end if
		  next
		  
		  //todo Streets
		  'for i = 0 to ubound(streets)
		  for each t as Tile in streets
		    theTile = t
		    theScore = theTile.GetStreetScore
		    if theScore <> nil then //if an occupied monastery with full tiles has been found
		      thePlayer = GetPlayerByColor(theScore.GetOwnerColor)
		      if thePlayer <> nil then
		        pos = theTile.GetPosition
		        thePlayer.SetScore theScore.GetScore
		        'theTile.grid.FreeSlots
		        theTile.RemoveOwner
		        Remove theTile
		        app.Dbg = app.dbg + "Player " + thePlayer.getName + " gets Points for finishing Street("+ str(pos.x) + "/" + str(pos.y)+ "): " + str(theScore.GetScore)  + EndOfLine
		        for each u as Tile in theScore.tiles
		          dim idx as integer
		          idx = streets.IndexOf(u)
		          broom.append u
		          if idx > -1 then
		            streets.Remove idx
		          end if
		        next
		      end if
		    end if
		  next
		  
		  
		  for each t as Tile in towns
		    theTile = t
		    theScore = theTile.getTownScore
		    if theScore <> nil then //if an occupied town with full tiles has been found
		      if theScore.IsEven = false then
		        
		        thePlayer = GetPlayerByColor(theScore.GetOwnerColor)
		        if thePlayer <> nil then
		          pos = theTile.GetPosition
		          thePlayer.SetScore theScore.GetScore
		          theTile.RemoveOwner
		          remove theTile
		          app.Dbg = app.dbg + "Player " + thePlayer.getName + " gets Points for finishing Town("+ str(pos.x) + "/" + str(pos.y)+ "): " + str(theScore.GetScore)  + EndOfLine
		          for each u as Tile in theScore.tiles
		            dim idx as integer
		            idx = towns.IndexOf(u)
		            broom.append u
		            if idx > -1 then
		              towns.Remove idx
		            end if
		          next
		        end if
		      end if
		    end if
		  next
		  
		  
		  for each t as Tile in broom
		    t.RemoveOwner
		  next
		  
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GetPlayerByColor(c as color) As game.player
		  dim i as integer
		  dim thePlayer as game.Player
		  
		  
		  for i = 0 to ubound(players)
		    if players(i).GetColor = c then
		      thePlayer = players(i)
		      exit for
		    end if
		  next i
		  
		  return thePlayer
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GetPlayerByName(n as string) As game.Player
		  dim i as integer
		  dim thePlayer as game.Player
		  
		  
		  for i = 0 to ubound(players)
		    if players(i).GetName = n then
		      thePlayer = players(i)
		      exit for
		    end if
		  next i
		  
		  return thePlayer
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub Remove(t as Tile)
		  //remove the gamepieces
		  
		  dim tileType as String
		  dim i as integer
		  
		  
		  tileType = t.grid.GetOccupiedType
		  
		  if tileType = "Monastery" then
		    i = monasteries.IndexOf(t)
		    if i > -1 then
		      monasteries.Remove i
		      t.grid.FreeSlots
		    end if
		  end if
		  
		  if tileType = "Town" then
		    i = towns.IndexOf(t)
		    if i > -1 then
		      towns.Remove i
		      t.grid.FreeSlots
		    end if
		  end if
		  
		  if tileType = "Street" then
		    i = streets.IndexOf(t)
		    if i > -1 then
		      streets.Remove i
		      t.grid.FreeSlots
		    end if
		    
		  end if
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GetBag() As Tilebag
		  return self.bag
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GetBoard() As board.gameboard
		  return board
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub Go()
		  currentPlayer.Activate
		  
		  while not bag.IsEmpty
		    'CleanUp
		    NextPlayer
		  wend
		  CalculateFinalScore
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub EndGame()
		  //todo
		  
		  dim i as integer
		  
		  
		  
		  CalculateFinalScore
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  for i = 0 to ubound(players)
		    MsgBox players(i).GetName + ": " + str(players(i).GetScore)
		  next
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub CalculateFinalScore()
		  dim i as integer
		  dim j as integer
		  'dim theTile as Tile
		  dim theScore as game.Score
		  dim thePlayer as game.Player
		  dim pos as Coordinates
		  
		  for each theTile as Tile in monasteries
		    'theTile = monasteries(i)
		    'thetile = t
		    theScore = theTile.GetFinalMonasteryEstates
		    if theScore <> nil then //if an occupied monastery with full tiles has been found
		      thePlayer = GetPlayerByColor(theScore.GetOwnerColor)
		      if thePlayer <> nil then
		        pos = theTile.GetPosition
		        thePlayer.SetScore theScore.GetScore
		        app.Dbg = app.dbg + "Player " + thePlayer.getName + " final score for Monastery("+ str(pos.x) + "/" + str(pos.y)+ "): " + str(theScore.GetScore)  + EndOfLine
		        'theTile.grid.FreeSlots
		        'monasteries.Remove monasteries.IndexOf(theTile)
		      end if
		    end if
		    app.Dbg = app.dbg + "--------------------------------------------------------" + EndOfLine
		  next
		  
		  dim visitedStreets() as Tile
		  
		  '//todo Streets
		  'for i = 0 to ubound(streets)
		  for each theTile as Tile in streets
		    if visitedStreets.IndexOf(theTile) = - 1 then
		      theScore = theTile.GetFinalStreetScore
		      if theScore <> nil then
		        thePlayer = GetPlayerByColor(theScore.GetOwnerColor)
		        if thePlayer <> nil then
		          pos = theTile.GetPosition
		          thePlayer.SetScore theScore.GetScore
		          app.Dbg = app.dbg + "Player " + thePlayer.getName + " final score for Street("+ str(pos.x) + "/" + str(pos.y)+ "): " + str(theScore.GetScore)  + EndOfLine
		          for each visited as Tile in theScore.tiles
		            visitedStreets.Append visited
		          next
		        end if
		      end if
		      app.Dbg = app.dbg + "--------------------------------------------------------" + EndOfLine
		    end if
		  next
		  
		  dim visitedTowns() as Tile
		  
		  for each theTile as Tile in towns
		    if visitedTowns.IndexOf(theTile) = -1 then
		      theScore = theTile.getFinalTownScore
		      if theScore <> nil then
		        if theScore.IsEven = false then
		          thePlayer = GetPlayerByColor(theScore.GetOwnerColor)
		          if thePlayer <> nil then
		            pos = theTile.GetPosition
		            thePlayer.SetScore theScore.GetScore
		            app.Dbg = app.dbg + "Player " + thePlayer.getName + " final score for Town +("+ str(pos.x) + "/" + str(pos.y)+ "): " + str(theScore.GetScore)  + EndOfLine
		            for each visited as Tile in theScore.tiles
		              visitedTowns.Append visited
		            next
		          else
		            app.RaiseError(403, "Tile occupied by a player that is not in game", "ConcreteGame.GetFinalScore", 2)
		          end if
		        end if
		      end if
		      app.Dbg = app.dbg + "--------------------------------------------------------" + EndOfLine
		    end if
		  next
		  
		  for i = 0 to ubound(players)
		    app.Dbg = app.Dbg + "Final Score for Player " + players(i).getName + ": " + str(players(i).GetScore) + EndOfLine
		  next
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h21
		Private Sub CleanUp()
		  dim i as integer
		  dim mArr() as integer
		  dim sArr() as integer
		  dim tArr() as integer
		  
		  for i = 0 to ubound(monasteries)
		    if monasteries(i).GetOwner = nil then
		      mArr.Append i
		    end if
		  next
		  
		  for i = 0 to ubound(mArr)
		    monasteries.Remove mArr(i)
		  next
		  
		  for i = 0 to ubound(towns)
		    if towns(i).GetOwner = nil then
		      tArr.Append i
		    end if
		  next
		  
		  for i = 0 to ubound(tArr)
		    towns.Remove tArr(i)
		  next
		  
		  for i = 0 to ubound(streets)
		    if streets(i).GetOwner = nil then
		      sArr.Append i
		    end if
		  next
		  
		  for i = 0 to ubound(sArr)
		    streets.Remove sArr(i)
		  next
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub TestGo()
		  #if DebugBuild
		    currentPlayer.Activate
		  #endif
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub WriteLog(msg as string)
		  log = log + msg
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Function ReadLog() As string
		  return log
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub AddGameNo(no as integer)
		  log = "Game Nr. " + str(no) + EndOfLine + log
		End Sub
	#tag EndMethod


	#tag Property, Flags = &h21
		Private bag As Tilebag
	#tag EndProperty

	#tag Property, Flags = &h21
		Private board As board.Gameboard
	#tag EndProperty

	#tag Property, Flags = &h21
		Private currentPlayer As Player
	#tag EndProperty

	#tag Property, Flags = &h21
		Private currentTile As Tile
	#tag EndProperty

	#tag Property, Flags = &h21
		Private Shared gameInstance As ConcreteGame
	#tag EndProperty

	#tag Property, Flags = &h21
		Private players() As Player
	#tag EndProperty

	#tag Property, Flags = &h21
		Private round As Integer = 0
	#tag EndProperty

	#tag Property, Flags = &h0
		monasteries() As tile
	#tag EndProperty

	#tag Property, Flags = &h0
		towns() As Tile
	#tag EndProperty

	#tag Property, Flags = &h0
		streets() As Tile
	#tag EndProperty

	#tag Property, Flags = &h21
		Private log As string
	#tag EndProperty


	#tag ViewBehavior
		#tag ViewProperty
			Name="Name"
			Visible=true
			Group="ID"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Index"
			Visible=true
			Group="ID"
			InitialValue="-2147483648"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Super"
			Visible=true
			Group="ID"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Left"
			Visible=true
			Group="Position"
			InitialValue="0"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Top"
			Visible=true
			Group="Position"
			InitialValue="0"
			InheritedFrom="Object"
		#tag EndViewProperty
	#tag EndViewBehavior
End Class
#tag EndClass
